Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report positionless tsconfig option errors on compilerOptions key #58254

Conversation

andrewbranch
Copy link
Member

Any program error that is talking about a compiler option but can’t find an option name/value to report the error on now reports the error on the compilerOptions key (if present) instead of positionlessly in the file. I noticed while investigating #58214 that these positionless errors are very easy to miss in the editor.

Before:

image

After:

image

A common one that’s still positionless is “Cannot write file 'foo.js' because it would overwrite input file.” We could consider moving that to compilerOptions too since the correct fix is to add either outDir or noEmit 99% of the time, along with suggesting that in the error message. Anyone have opinions on that?

Comment on lines 7 to +9
"compilerOptions": {
~~~~~~~~~~~~~~~~~
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
Copy link
Member Author

@andrewbranch andrewbranch Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this test is simulating a combination of tsconfig options and CLI flags. This would have been reported on "moduleResolution": "bundler" if it were in the tsconfig, but it was passed in as a flag instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh

src/compiler/program.ts Outdated Show resolved Hide resolved
src/compiler/program.ts Outdated Show resolved Hide resolved
@andrewbranch andrewbranch merged commit e75f470 into microsoft:main Apr 19, 2024
25 checks passed
@andrewbranch andrewbranch deleted the report-options-errors-on-compilerOptions branch April 19, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants